<?php
/*
 * @Date: 2025-08-19 22:05:25
 * @LastEditors: 贾二小 erxiao.jia@outlook.com
 * @LastEditTime: 2025-09-07 20:03:35
 * @FilePath: /admin-api/app/Models/Role.php
 */

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Spatie\Permission\Models\Role as ModelsRole;

class Role extends ModelsRole
{
    /** @use HasFactory<\Database\Factories\RoleFactory> */
    use HasFactory;


    protected $fillable = ['name', 'description'];


    public function scopeKey(Builder $query, ?string $value): void
    {
        if ($value) {
            $query->where(
                fn (Builder $query) => $query->orWhere('name', 'like', '%' . $value . '%')
            );
        }
    }
}
